@extends('layouts.backend')
@section('title')
    编辑管理员
@endsection
@section('css')
    <link href="{{asset('css/plugins/select2/select2.min.css')}}" rel="stylesheet">
@endsection
@section('body')
    <div class="row">
        <div class="ibox">
            <div class="ibox-title">
                <h5>编辑管理员</h5>
                <a href="{{route('backend.admin.index')}}" class="btn btn-primary pull-right">返回列表</a>
                <div class="clearfix"></div>
            </div>
            <div class="ibox-content">
                <div class="row m-sm">
                    <div class="col-md-8">
                        <form method="post" class="form-horizontal" >
                            @csrf
                            <input type="hidden" name="_method" value="PUT">
                            <div class="form-group">
                                <label >用户名@include('components.backend.required')</label>
                                <input type="text" name="name" placeholder="请输入用户名" value="{{$admin->name}}" class="form-control" required>
                            </div>
                            <div class="form-group">
                                <label >Email @include('components.backend.required')</label>
                                <input type="text" name="email" disabled="disabled" placeholder="请输入邮箱" value="{{$admin->email}}" class="form-control" required>
                            </div>
                            <div class="form-group">
                                <label>密码(可选)</label>
                                <input type="text" name="password" placeholder="请输入密码" class="form-control" >
                            </div>
                            <div class="form-group">
                                <label >密码(可选)</label>
                                <input type="text" name="password_confirmation" placeholder="请再输入一次密码" class="form-control" >
                            </div>
                            <div class="form-group">
                                <label>角色 @include('components.backend.required')</label>
                                <select id="role" name="role_name[]" multiple="multiple" class="form-control" multiple="multiple">
                                    @foreach($roles as $role)
                                        <option value="{{ $role->name }}" {{$admin->hasRole($role->name) ? 'selected' : ''}}>{{ $role->name }}</option>
                                    @endforeach
                                </select>

                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <button class="btn btn-primary" type="submit">保存</button>
                            </div>
                        </form>
                    </div>
                </div>

            </div>
        </div>
</div>
@endsection
@section('js')
    <script src="{{asset('js/plugins/select2/select2.full.min.js')}}"></script>
    <script>
        $(document).ready(function() {
            $('#role').select2();
        });
    </script>
@endsection
